package com.etone.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.etone.common.annotation.Log;
import com.etone.common.core.controller.BaseController;
import com.etone.common.core.domain.AjaxResult;
import com.etone.common.enums.BusinessType;
import com.etone.system.domain.FiveCtuRrecord;
import com.etone.system.service.IFiveCtuRrecordService;
import com.etone.common.utils.poi.ExcelUtil;
import com.etone.common.core.page.TableDataInfo;

/**
 * CTU入库记录Controller
 *
 * @author etone
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/system/rrecord")
public class FiveCtuRrecordController extends BaseController
{
    @Autowired
    private IFiveCtuRrecordService fiveCtuRrecordService;

    /**
     * 查询CTU入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(FiveCtuRrecord fiveCtuRrecord)
    {
        startPage();
        List<FiveCtuRrecord> list = fiveCtuRrecordService.selectFiveCtuRrecordList(fiveCtuRrecord);
        return getDataTable(list);
    }

    /**
     * 导出CTU入库记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:export')")
    @Log(title = "CTU入库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FiveCtuRrecord fiveCtuRrecord)
    {
        List<FiveCtuRrecord> list = fiveCtuRrecordService.selectFiveCtuRrecordList(fiveCtuRrecord);
        ExcelUtil<FiveCtuRrecord> util = new ExcelUtil<FiveCtuRrecord>(FiveCtuRrecord.class);
        util.exportExcel(response, list, "CTU入库记录数据");
    }

    /**
     * 获取CTU入库记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fiveCtuRrecordService.selectFiveCtuRrecordById(id));
    }

    /**
     * 新增CTU入库记录
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:add')")
    @Log(title = "CTU入库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FiveCtuRrecord fiveCtuRrecord)
    {
        return toAjax(fiveCtuRrecordService.insertFiveCtuRrecord(fiveCtuRrecord));
    }

    /**
     * 修改CTU入库记录
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:edit')")
    @Log(title = "CTU入库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FiveCtuRrecord fiveCtuRrecord)
    {
        return toAjax(fiveCtuRrecordService.updateFiveCtuRrecord(fiveCtuRrecord));
    }

    /**
     * 删除CTU入库记录
     */
    @PreAuthorize("@ss.hasPermi('system:rrecord:remove')")
    @Log(title = "CTU入库记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fiveCtuRrecordService.deleteFiveCtuRrecordByIds(ids));
    }
}
